Skip to content

refactor(operator-trend): collapse tier-rollup summary renderers onto a parametrized base (T3-2 phase 6f)#88

Merged
saagpatel merged 1 commit into
mainfrom
refactor/operator-trend-collapse-summary-tiers
Jun 20, 2026
Merged

refactor(operator-trend): collapse tier-rollup summary renderers onto a parametrized base (T3-2 phase 6f)#88
saagpatel merged 1 commit into
mainfrom
refactor/operator-trend-collapse-summary-tiers

Conversation

@saagpatel

Copy link
Copy Markdown
Owner

What

Collapse the three reset-reentry tier-rollup summary renderers
..._rebuild_summary, ..._rebuild_reentry_restore_summary,
..._rebuild_reentry_restore_rerererestore_summary — onto one
_tier_summary_base + a _TierSummarySpec NamedTuple + three per-tier specs.
Each public function is now a thin wrapper with its exact original signature.

Why

The three were structural clones (AST-identical after literal-blanking),
differing only in:

  • the status key they read,
  • the per-tier status tokens, and
  • the reworded prose.

The status-string render skeleton was triplicated — the same drift risk that
already produced two real bugs earlier in this campaign (the phase-5 floor and
freshness-flag fixes). A future status branch now lands once, not three times.

Proof of byte-identical behavior

  1. Exhaustive branch differential — 168 cases per tier (504 total) spanning
    every status branch, both hotspot fallbacks, blocked-reason present/absent,
    and label / hotspot-label combinations: real(input) == base(input, spec)
    for every case.
  2. Composer golden contract — zero diff (tests/test_composer_golden_contract.py,
    47 passed).

The prose templates ({label} / {hotspot_label} str.format strings) were
extracted from the source AST, never hand-typed, so the contract text is exact.

Verification

  • uv run pytest -q → 2539 passed, 2 skipped
  • uv run mypy src/operator_trend_closure_forecast_reset_controls.py → clean
  • uv run ruff check src/ tests/ → clean

Net 136 insertions / 138 deletions (near line-neutral by design — these
renderers are mostly prose; the win is eliminating the triplicated render
skeleton and its drift risk, consistent with the phase-6 collapses).

… a parametrized base (T3-2 phase 6f)

Collapse the rebuild / restore / rerererestore reset-reentry summary
renderers onto one `_tier_summary_base` + `_TierSummarySpec` + per-tier
specs. The three were structural clones differing only in the status key
they read, the per-tier status tokens, and reworded prose; the shared
status-string render skeleton was triplicated, the same drift risk that
produced the phase-5 floor/freshness fixes.

Proven byte-identical two ways: an exhaustive branch differential (168
cases per tier, spanning every status branch, hotspot fallback,
blocked-reason presence, and label / hotspot-label combination) and the
composer golden contract (zero diff). Public signatures unchanged; the
prose templates were extracted from the source AST, never hand-typed.
@saagpatel saagpatel merged commit 3473e5b into main Jun 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant